<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
    <h:body>	
		<ui:composition template="/admin/template.xhtml">		    			
		<p:panel header="Uživatelé">	
			<h:panelGrid columns="2">
				<p:panel header="Editace uživatelů" style="min-height: 1129px;">   
				   <h:form id="seasonForm">	
					    	<p:dataTable id="seaspmTable" var="user" value="#{userBean.userList}" rowKey="#{user.id}" paginator="true" rows="15" paginatorAlwaysVisible="false" paginatorPosition="bottom" selection="#{userBean.selectedUser}" selectionMode="single" tableStyle="min-width:300px;">
						        <f:facet name="header">
									<h:outputText value="Seznam uživatelů" />
						        </f:facet>
						        <p:column headerText="přihlašovací jméno" >  
						            <h:outputText value="#{user.username}" />  
						        </p:column>
						        <p:column headerText="heslo" >  
						            <h:outputText value="#{user.password}" />  
						        </p:column>
						        <p:column headerText="zaslán e-mail" >  
						            <h:outputText value="#{user.send}" />  
						        </p:column>
						        <f:facet name="footer">  
					            	<p:commandButton  icon="ui-icon-pencil" value="upravit uživatele" update=":dialog" oncomplete="seasonDialog.show()"/>
					            	<p:commandButton  icon="ui-icon-document" actionListener="#{userBean.deleteUser}" value="smazat uživatele"  update=":seasonForm:" rendered="false"/>   
					                <p:commandButton  icon="ui-icon-document" value="nový uživatel"  update=":seasonForm:" oncomplete="seasonNewDialog.show()"/>
					                <p:commandButton  icon="ui-icon-document" actionListener="#{userBean.sendMail}" value="poslat email"  update=":seasonForm:" />  					            
					       		</f:facet>     
					  	    </p:dataTable>
					</h:form>
					<p:dialog id="dialog" header="Editace uživatele" widgetVar="seasonDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid columns="2" cellpadding="4">
						      	       <h:outputText value="přihlašovací jméno" />    						      
							           <h:inputText value="#{userBean.selectedUser.username}" style="width:150px" required="true"/>
							           <h:outputText value="heslo" />    						      
							           <h:inputText value="#{userBean.selectedUser.password}" style="width:150px" required="true"/>  
							           <h:outputText value="e-mail" />    						      
							           <h:inputText value="#{userBean.selectedUser.email}" style="width:150px" required="true"/>      	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Ulož změny"  actionListener="#{userBean.updateUser}" update=":seasonForm,:growl" oncomplete="seasonDialog.hide()"/> 
						        </h:form>	
					 </p:dialog>
				     <p:dialog id="dialogNew" header="Nový uživatel" widgetVar="seasonNewDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid columns="2" cellpadding="4">
						      	       <h:outputText value="přihlašovací jméno" />    						      
							           <h:inputText value="#{userBean.newUser.username}" style="width:150px" required="true"/>
							           <h:outputText value="e-mail" />    						      
							           <h:inputText value="#{userBean.newUser.email}" style="width:150px" required="true"/>      	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Vytvoř uživatele"  actionListener="#{userBean.createUser}" update=":seasonForm,:dialogNew,:growl" oncomplete="seasonNewDialog.hide()"/> 
						        </h:form>	
					</p:dialog>
					
				</p:panel>
			</h:panelGrid>
		</p:panel>			
		</ui:composition>	
	</h:body>
</html>